package com.rd.server.framework.config;

import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * Description:
 *
 * @author zyy
 * @date 2025/4/9 14:25
 */
@Component
public class DateConverter implements Converter<String, Date> {

    @Override
    public Date convert(String source) {
        try {
            // 假设输入的是毫秒级时间戳
            long timestamp = Long.parseLong(source);
            return new Date(timestamp);
        } catch (NumberFormatException e) {
            throw new IllegalArgumentException("Failed to convert from String to Date for value [" + source + "]", e);
        }
    }
}
